package com.zyw.codegen;

import org.apache.commons.lang3.StringUtils;

import java.io.File;

/**
 * @author zhangyw
 * @date 2017/2/27 17:44
 */
public class GenConfig {

    private String projectPath; // 项目根路径
    private String project; // 工程模块名
    private String moduleName; // 业务模块名称
    private String subModuleName; // 业务子模块名称 可不填写
    private String packageName; // 包名

    private String functionAuthor;
    private String functionName;
    private String functionVersion;
    private String functionDate;

    private String xmlMergeable; // 是否合并xml
    private boolean overwriteEnabled; // 是否覆盖文件，默认false

    public String getProjectPath() {
        return projectPath;
    }

    public void setProjectPath(String projectPath) {
        this.projectPath = projectPath;
    }

    public String getProject() {
        return project;
    }

    public void setProject(String project) {
        this.project = project;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public String getSubModuleName() {
        return subModuleName;
    }

    public void setSubModuleName(String subModuleName) {
        this.subModuleName = subModuleName;
    }

    public String getFunctionAuthor() {
        return functionAuthor;
    }

    public void setFunctionAuthor(String functionAuthor) {
        this.functionAuthor = functionAuthor;
    }

    public String getFunctionName() {
        return functionName;
    }

    public void setFunctionName(String functionName) {
        this.functionName = functionName;
    }

    public String getFunctionVersion() {
        return functionVersion;
    }

    public void setFunctionVersion(String functionVersion) {
        this.functionVersion = functionVersion;
    }

    public String getFunctionDate() {
        return functionDate;
    }

    public void setFunctionDate(String functionDate) {
        this.functionDate = functionDate;
    }

    public String getXmlMergeable() {
        return xmlMergeable == null ? "false" : xmlMergeable;
    }

    public void setXmlMergeable(String xmlMergeable) {
        this.xmlMergeable = xmlMergeable;
    }

    public boolean isOverwriteEnabled() {
        return overwriteEnabled;
    }

    public void setOverwriteEnabled(boolean overwriteEnabled) {
        this.overwriteEnabled = overwriteEnabled;
    }

    public String getJavasourcePath() {
        StringBuffer sb = new StringBuffer();
        sb.append(this.getProjectPath()).append(File.separator);

        if (StringUtils.isNotEmpty(this.project)) {
            sb.append(this.project).append(File.separator);
        }

        sb.append("src")
                .append(File.separator)
                .append("main")
                .append(File.separator)
                .append("java");
        return sb.toString();
    }

    public String getResourcePath() {
        StringBuffer sb = new StringBuffer();
        sb.append(this.getProjectPath()).append(File.separator);

        if (StringUtils.isNotEmpty(this.project)) {
            sb.append(this.project).append(File.separator);
        }
        sb.append("src")
                .append(File.separator)
                .append("main")
                .append(File.separator)
                .append("resources");
        return sb.toString();
    }
}
